﻿using System;
using System.Windows.Forms;
using LANChatCore;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling;

namespace LANChatClient
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            try
            {
                //// Examples of how to use the Logger
                //LogEntry le = new LogEntry()
                //{
                //    Categories = "General",
                //    Severity = System.Diagnostics.TraceEventType.Information

                //    Message = GeneralStrings.LanChatStart,
                //    MachineName = Environment.MachineName,
                //};
                //Logger.Write(le);                

                LogHelper.Log(GeneralStrings.LanChatStart);

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new ClientMain());
            }
            catch (Exception e)
            {
                // We do not need to explicitly log exceptions like this
                //Logger.Write("Error: " + ex.Message + "\n" + ex.Source);

                // All exceptions are logged by ExceptionPolicy.HandleException
                // Follow the convention below when handling exceptions
                // app.config has a configuration, which is named "Exception Policy",
                // that will automatically log the exception using the Logging Application
                // Block. Read http://www.codeproject.com/KB/aspnet/ExceptionHandling.aspx .
                // The article is a little out of date, (we are on Enterprise Library 4.1) but
                // the concept is the same. Also, download and install 
                // http://www.microsoft.com/downloads/details.aspx?FamilyId=1643758B-2986-47F7-B529-3E41584B6CE5&displaylang=en
                // and become familiar with the Enterprise Library Configuration tool which
                // allows you to configure how the logger and exception handling blocks work

                //ex usage
                //bool rethrow = ExceptionPolicy.HandleException(e, GeneralStrings.GetDefaultExPolicy);
                //if (rethrow)
                //    throw;

                ExceptionPolicy.HandleException(e, GeneralStrings.GetDefaultExPolicy);
            }
        }
    }
}
